<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * Copyright (C) 2007  Robert Moss
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 

?>

<form action="index2.php" method="post" name="adminForm">
<div id="right">
	<div id="rightpad">
	
<!-- Header START -->	
		<div id="step">
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
				<div class="far-right">
							<div class="button1-left"><div class="help"><a href="http://www.joomleague.de/handbuch.html" alt="<?php echo _JL_ADMIN_MANUAL;?>" title="<?php echo _JL_ADMIN_MANUAL;?>" target="blank"><?php echo _JL_ADMIN_MANUAL;?></a></div></div>
							<div class="button1-left"><div class="forum"><a href="http://www.joomleague.de/forum/" alt="<?php echo _JL_ADMIN_FORUM;?>" title="<?php echo _JL_ADMIN_FORUM;?>" target="blank"><?php echo _JL_ADMIN_FORUM;?></a></div></div>
							<div class="button1-left"><div class="about"><a href="http://www.joomleague.de" alt="<?php echo _JL_ADMIN_INFO;?>" title="<?php echo _JL_ADMIN_INFO;?>" target="blank"><?php echo _JL_ADMIN_INFO;?></a></div></div>
				</div>
				<div class="button1-left"><div class="blank"><a href="index2.php?option=com_joomleague"></a></div></div><span class="step"><?php echo $team->name;?><?php echo _JL_ADMIN_ASSIGN_PLAYERS_PLAYERS;?></span>
			</div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
    </div>
<!-- Header END --> 

    <div id="installer">
    
<!-- Title START -->    
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
      	<h2><?php echo _JL_ADMIN_ASSIGN_PLAYERS_TITLE;?></h2>		
<!-- Titel END -->         		 
  
<!-- Info START -->   			
		<div id="step">
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
<table class="content" cellpadding="4">
 <tr>
  <td><?php echo _JL_ADMIN_ASSIGN_PLAYERS_HINT1;?>
  </td>
 </tr>
</table>
			</div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
    </div>
<!-- Info END -->

<!-- Navigation, Search etc. START-->   			
		<div id="step">
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
<table class="content" cellpadding="4">
  <tr>
    <td>
      <?php echo _JL_ADMIN_ASSIGN_PLAYERS_FILTER;?><input type="text" class="inputbox" size="30" name="search" value="" onKeyup="javascript:myfilter.set('^'+this.value)"
    </td>
  </tr>
</table>
			</div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
    </div>
<!-- Navigation, Search etc. END -->     
  	
<!-- Content START -->				
				<div class="install-text2">
	<table cellpadding="4" cellspacing="0" border="0" width="100%" align="center">
  	<thead>
      <tr>
        <td align="center">
          <?php echo mosHTML::selectList( $player1, 'list1', 'class="inputbox" size="20" multiple="multiple" onDblClick="move(document.adminForm.list1,document.adminForm.list2)" style="width:350px;"','value', 'text','');?>
        </td>
        <td align="center">
          <input type="button" class="button" value="&raquo;" style="width:30px;" onClick="move(this.form.list1,this.form.list2)"/><br /><br />     
          <input type="button" class="button" value="&laquo;" style="width:30px;" onClick="move(this.form.list2,this.form.list1)"/>
        </td>
        <td align="center">
          <?php echo mosHTML::selectList( $player2, 'list2','class="inputbox" size="20" multiple="multiple" onDblClick="move(document.adminForm.list2,document.adminForm.list1)" style="width:350px"','value','text','');?>
          <input type="hidden" name="players" value=""/>
        </td>
      </tr>
  	</thead>
	</table>
<script type="text/javascript" src="components/com_joomleague/js/filterlist.js"></script>

<script type="text/javascript">
  function submitbutton(pressbutton) {
            
      var form = document.adminForm;
      if (pressbutton == 'cancel') {
        submitform( pressbutton );
        return;
      }
      
      saveMe('list2','players');
      submitform( pressbutton );
      
  }
  
  function saveMe(box,field) {
      var strValues = "";
      var boxLength = document.adminForm.elements[box].length;
      var count = 0;
      if (boxLength != 0) {
        for (i = 0; i < boxLength; i++) {
          if (count == 0) {
            strValues = document.adminForm.elements[box].options[i].value;
          }
          else {
            strValues = strValues + "," + document.adminForm.elements[box].options[i].value;
          }
          count++;
        }
      }
      //alert(strValues);
      document.adminForm.elements[field].value = strValues;
  }

  function move(fbox, tbox) {
       var arrFbox = new Array();
       var arrTbox = new Array();
       var arrLookup = new Array();
       var i;
       for(i=0; i<tbox.options.length; i++) {
            arrLookup[tbox.options[i].text] = tbox.options[i].value;
            arrTbox[i] = tbox.options[i].text;
       }
       var fLength = 0;
       var tLength = arrTbox.length
       for(i=0; i<fbox.options.length; i++) {
            arrLookup[fbox.options[i].text] = fbox.options[i].value;
            if(fbox.options[i].selected && fbox.options[i].value != "") {
                 arrTbox[tLength] = fbox.options[i].text;
                 tLength++;
            } else {
                 arrFbox[fLength] = fbox.options[i].text;
                 fLength++;
            }
       }
       arrFbox.sort();
       arrTbox.sort();
       fbox.length = 0;
       tbox.length = 0;
       var c;
       for(c=0; c<arrFbox.length; c++) {
            var no = new Option();
            no.value = arrLookup[arrFbox[c]];
            no.text = arrFbox[c];
            fbox[c] = no;
       }
       for(c=0; c<arrTbox.length; c++) {
       	var no = new Option();
       	no.value = arrLookup[arrTbox[c]];
       	no.text = arrTbox[c];
       	tbox[c] = no;
       }
  }

  function selectAll(box) {
  
    for(var i=0; i<box.length; i++) {
      box[i].selected = true;
    }
  }
  
  var myfilter = new filterlist(document.adminForm.list1);
</script>
				</div>
<!-- Content END -->	
			
        <div class="clr"></div>
      </div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
		</div>
	</div>
</div>
<div class="clr"></div>
    <input type="hidden" name="project_id" value="<?php echo $project->id;?>">
		<input type="hidden" name="option" value="<?php echo $option;?>" />
    <input type="hidden" name="act" value="<?php echo $act;?>" />
		<input type="hidden" name="task" value="" />
</form>
